export default {
  props: {
    query: {
      type: Object,
      default: () => {
        return { total: 0, size: 25, page: 1 };
      },
    },
    pageSizes: {
      type: Array,
      default: () => {
        return [25, 50, 75, 100, 200];
      },
    },
  },
  mounted() {
    this.page = this.query;
  },
  watch: {
    query() {
      console.log(this.query);
      this.page = this.query;
    },
  },
  methods: {
    /**
     * 更改数量
     * @param {*} val
     */
    handleSizeChange(val) {
      this.$emit('paginationChange', { page: this.page.page, size: val, total: this.query.total });
    },
    /**
     * 更改分页
     * @param {*} val
     */
    handleCurrentChange(val) {
      this.$emit('paginationChange', { page: val, size: this.page.size, total: this.query.total });
    },
  },
  data() {
    return {
      page: {
        page: 1,
        size: 25,
        total: 0,
      },
    };
  },
};
